home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / SLIDER-V.DMO < prev    next >
Text File  |  1996-07-04  |  5KB  |  77 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   SLIDER-V.DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NBT1.INC"
  22. $INCLUDE "KEYCODES.INC"
  23.  
  24. COLOR 7, 0
  25. CLS
  26. ? "┌───────────────────────────────────────────────────────────────────
  27. ? "│ TsliderV ( Row?, Col?, Rows?, Items%, Hot% ) ' vertical
  28. ? "│ TsliderH ( Row?, Col?, Cols?, Items%, Hot% ) ' horizontal
  29. ? "├──────────────────────────────────────────────────────────────────────
  30. ? "│ These are menu position indicators. Items% is the total number of items
  31. ? "│ in the menu and Hot% is the selected item number .
  32. ? "│ For our demo we're simulating a menu with 50 items. You move through
  33. ? "│ the list using UP and DOWN. Press ESC to end the demo.
  34. ? "└─────────────────────────────────────────────────────────────────────────
  35.                                                    '┌───────────────────────
  36. TBoxDRAW   10, 17, 13, 16, 1, 15                   '│ a little menu box
  37. TBoxDRAWv  10, 30, 13,     1,  1                   '│ with a vert box right
  38. TBoxColor  11, 31, 11,  1,    10                   '│ a new attr in the v-box
  39. TBoxColor  16, 18,  1, 12,    31                   '│ and a selection bar
  40.                                                    '│
  41. Hot% = 1                                           '│ gotta start somewhere
  42. DO                                                 '│ menu? loop
  43.   IF P% <> Hot% THEN                               '│ if we need to reprint
  44.     Row? = 11                                      '│ top row
  45.     FOR P% = ( Hot% - 5 ) TO ( Hot% + 5 )          '│ I like my selection bar
  46.       IF ( P% < 1 ) OR ( P% > 50 ) THEN            '│ to stay in one place as
  47.           I$ = "░░░░░░░░░░"                        '│ it reduces eye strain
  48.         ELSE                                       '│ for the user
  49.           I$ = USING$( "Item N° ##", P% )          '│
  50.       END IF                                       '│
  51.       Tprint Row?, 19, I$, 0                       '│ Att? = 0 so I don't
  52.       INCR Row?, 1                                 '│ have to compute it
  53.     NEXT                                           '│
  54.     P% = Hot%                                      '│ set the re-print flag
  55.   END IF                                           '│
  56.   TsliderV 11, 31, 11, 50, Hot%                    '│ reprint the slider
  57.   SELECT CASE fGetKey%                             '│ act on key-press
  58.     CASE %HOME_key   : Hot% = 1                    '│ top of list
  59.     CASE %UP_key     : Hot% = MAX(  1, Hot% -  1 ) '│ up one
  60.     CASE %PGUP_key   : Hot% = MAX(  1, Hot% - 10 ) '│ up a page full - 1
  61.     CASE %END_key    : Hot% = 50                   '│ end of the list
  62.     CASE %DOWN_key   : Hot% = MIN( 50, Hot% +  1 ) '│ down one
  63.     CASE %PGDN_key   : Hot% = MIN( 50, Hot% + 10 ) '│ down a page full -1
  64.     CASE %ENTER_key  : EXIT LOOP                   '│ all done!
  65.     CASE %ESC_key    : EXIT LOOP                   '│ <ditto>
  66.   END SELECT                                       '│
  67.                                                    '│
  68. LOOP                                               '│ dah...
  69. CLS                                                '│ did we just write a
  70. END                                                '│ whole menu function?
  71. ' ──────────────────────────────────────────────────┤
  72. FUNCTION fGetKey% LOCAL PUBLIC                     '│ seen this before?
  73.                                                    '│
  74.   WHILE NOT INSTAT : WEND                          '│
  75.   FUNCTION = CVI( INKEY$ + CHR$(0) )               '│
  76.                                                    '│
  77. END FUNCTION                                       '│